<?php

use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use app\modules\Customer\models\Customer;
use kartik\select2\Select2;

//获取客户 
$customers = Customer::all();  
$customers = yii\helpers\ArrayHelper::map($customers,'id','name');


?>

<div class="product-form">

    <?php $form = ActiveForm::begin([
             'options' => ['enctype' => 'multipart/form-data',],
             'layout' => 'horizontal',
             'fieldConfig' => [
                'template' => "{label}\n{beginWrapper}\n{input}\n{hint}\n{error}\n{endWrapper}",
                'horizontalCssClasses' => [
                    'label' => 'col-sm-2',
                    'wrapper' => 'col-sm-7',
                    'error' => '',
                ],
             ],
        ]); ?>

     <?= $form->field($model, 'customer_id')->widget(Select2::classname(), [
                'data' => $customers,
                'language' => 'zh-cn',
                'options' => ['placeholder' => '选择客户'],
                'pluginOptions' => [
                    'allowClear' => true,
                ],
            ]); ?>

    <?= $form->field($model, 'product_type')->inline(true)->radioList(Yii::$app->params['product_type']) ?>


    <?= $form->field($model, 'customer_code')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'p_name')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'p_phone')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'p_mail')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'p_department')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'remark')->textArea(['maxlength' => true]) ?>

    <div class="form-group text-center">
        <?= Html::submitButton(Yii::t('app', 'Save'), ['class' => 'btn btn-success']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
